<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>saz.js saz.deferred</title>
	<meta name="language" content="ja" />

	<script type="text/javascript" src="../libs/dojo/dojo.js"></script>
	<script type="text/javascript" src="../libs/easel.js"></script>
	<script type="text/javascript" src="../libs/tween.js"></script>

	<script type="text/javascript" src="js/saz.js"></script>
	<script type="text/javascript" src="js/saz.deferred.js"></script>

</head>
<body>

<h1 id="title">saz.js saz.deferred</h1>
<div id="container"></div>

<script type="text/javascript">

//var def0,def1,def2,def3,def4,def5,def6;

Ticker.setFPS(30);
var cnt = dojo.byId('container');
var tit = dojo.byId('title');
tit.style.position = 'absolute';
tit.style.left = '0px';
tit.style.top = '0px';
cnt.style.marginTop = '90px';

//-----------------------------------------------------------
/*
var def0 = new dojo.Deferred();
var def1 = def0.then(function(){
	console.log('A: wait');
	var p = document.createElement('p');
	p.innerHTML = 'A: wait';
	cnt.appendChild(p);
});
// then用メソッド
var def2 = def1.then(SAZ.deferred.thenWait(1000));
var def3 = def2.then(SAZ.deferred.thenLog('B: Tween'));
var def4 = def3.then(function() {
	return SAZ.deferred.tween(
		Tween.get(tit.style, {css:true})
			.to({left:100},400,Ease.bounceOut)
			.to({top:100},300,Ease.bounceOut)
			.to({left:0},200,Ease.bounceOut)
			.to({top:0},200,Ease.bounceOut)
	);
});
var def5 = def4.then(function() {
	console.log('C: wait');
	var p = document.createElement('p');
	p.innerHTML = 'C: wait';
	cnt.appendChild(p);
	
	return SAZ.deferred.wait(1000);
});
var def6 = def5.then(SAZ.deferred.thenLog('* COMP *'));
*/
//--------------------------↑↓意味は同じ
var def0 = new dojo.Deferred();
def0.then(function(){
	console.log('A: wait');
	var p = document.createElement('p');
	p.innerHTML = 'A: wait';
	cnt.appendChild(p);
})
.then(SAZ.deferred.thenWait(1000))
.then(SAZ.deferred.thenLog('B: Tween'))
.then(function() {
	return SAZ.deferred.tween(
		Tween.get(tit.style, {css:true})
			.to({left:100},400,Ease.bounceOut)
			.to({top:100},300,Ease.bounceOut)
			.to({left:0},200,Ease.bounceOut)
			.to({top:0},200,Ease.bounceOut)
	);
})
.then(function() {
	console.log('C: wait');
	var p = document.createElement('p');
	p.innerHTML = 'C: wait';
	cnt.appendChild(p);
	
	return SAZ.deferred.wait(1000);
})
.then(SAZ.deferred.thenLog('* COMP *'));
//-----------------------------------------------------------


console.log('* START *');
def0.resolve();

</script>

</body>
</html>
